package com.ukao.steward.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ukao.steward.R;
import com.ukao.steward.base.ListBaseAdapter;
import com.ukao.steward.base.SuperViewHolder;
import com.ukao.steward.bean.WaitingOrderBean;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.util.ActivityUtils;
import com.ukao.steward.util.CheckUtils;
import com.ukao.steward.util.MyDateUtils;

import java.util.List;


public class YetLetterAdapter extends ListBaseAdapter<WaitingOrderBean.ListBean> {



    public YetLetterAdapter(Context context, List<WaitingOrderBean.ListBean> mDataList) {
        super(context, mDataList);
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapte_yet_letterr;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, final int position) {
        TextView business=holder.getView(R.id.business);
        TextView orderNo=holder.getView(R.id.orderNo);
        TextView transNo=holder.getView(R.id.transNo);
        TextView takeName=holder.getView(R.id.takeName);
        TextView takePhone=holder.getView(R.id.takePhone);
        TextView statusTime=holder.getView(R.id.statusTime);
        TextView storeName=holder.getView(R.id.storeName);
        TextView userRemark=holder.getView(R.id.userRemark);
        TextView modifyPrice=holder.getView(R.id.modifyPrice);
        TextView payablePrice=holder.getView(R.id.payablePrice);
        LinearLayout modifyPriceLayout=holder.getView(R.id.modifyPrice_layout);
        LinearLayout payablePriceLayout=holder.getView(R.id.payablePrice_layout);
        LinearLayout takePhoneLayout=holder.getView(R.id.takePhone_layout);

        WaitingOrderBean.ListBean item = mDataList.get(position);
        transNo.setText(item.getTransNo());
        statusTime.setText(MyDateUtils.formatNoYeanTimes(item.getStatusTime()) );
        orderNo.setText(item.getOrderNo());
        takePhone.setText(item.getTakePhone());
        takeName.setText(item.getTakeName());

        userRemark.setText(item.getUserRemark());
        if (!CheckUtils.isEmpty(item.getBusiness())){
            business.setText(Constant.getbusiness(item.getBusiness()));
        }else{
            business.setText("");
        }

        payablePrice.setText(CheckUtils.isEmptyNumber(item.getPayablePrice()));
        modifyPrice.setText(CheckUtils.isEmptyNumber(item.getModifyPrice()));
        payablePrice.setTextColor(item.getPayStatus() ? getColors(R.color.green) : getColors(R.color.red));
        modifyPrice.setTextColor(item.getPayStatus() ? getColors(R.color.green) : getColors(R.color.red));
//        takePhoneLayout.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                WaitingOrderBean.ListBean item = mDataList.get(position);
//                if (v.getId()== R.id.takePhone_layout) {
//                    if (!CheckUtils.isEmpty(item.getTakePhone())) {
//                        ActivityUtils.callActivity(mContext, item.getTakePhone());
//                    }
//                }
//            }
//        });
    }


}
